﻿using System.IO;
using System.Runtime.Serialization;
using System.ServiceModel;

namespace RentIt06
{
    [ServiceContract]
    public interface IFileService
    {
        /// <summary>
        /// Uploads the file from the stream contained in the MediaUploadMessage to the server.
        /// </summary>
        /// <remarks>
        /// The token of the MediaUploadMessage must correspond to the one given from the
        /// GetUploadToken operation on the PublisherSession service.
        /// Furthermore, this method must be called within 30 minutes of receiving the upload token.<br/>
        /// If these requirements are not met, the file will be rejected immediately.
        /// The stream of the MediaUploadMessage contains the file to be uploaded.
        /// The file is verified serverside by way of the SHA512 hash given to the GetUploadToken
        /// operation that provided the token.
        /// </remarks>
        /// <param name="message">The message containing a 4 byte token and the file to upload.</param>
        [OperationContract]
        void UploadMedia(MediaUploadMessage message);

        /// <summary>
        /// Download the file associated with the given download token and media ID.
        /// </summary>
        /// <remarks>
        /// The token must correspond to the one given from the GetDownloadToken operation
        /// on the UserSession service.
        /// The given media ID must also correspond to the one given to the GetDownloadToken
        /// operation that provided the token.
        /// Furthermore, this method must be called within 30 minutes of receiving the token.<br/>
        /// </remarks>
        /// <param name="token">The 4 byte token authorizing the client for download.</param>
        /// <param name="id">The ID of the media file to download.</param>
        /// <returns>The stream containing the file to download.</returns>
        [OperationContract]
        Stream DownloadMedia(int token, int id);
    }
}
